# coding=gbk
from DBUtils import PersistentDB
import pymysql
from settings import *


class my_sqlpool:

    def __init__(self):
        self.host = MySql.get('host')
        self.user = MySql.get('user')
        self.password = MySql.get('password')
        self.db = MySql.get('db')
        self.port = MySql.get('port')
        self.persist = PersistentDB.PersistentDB(creator=pymysql,
                                                 maxusage=50, ping=0, threadlocal=None, closeable=False,
                                                 host=self.host,
                                                 user=self.user, password=self.password, database=self.db,
                                                 port=self.port, charset='utf8')
    def get_connect(self):
        return self.persist.connection()


if __name__ == '__main__':
    print(my_sqlpool().get_connect())
